package com.android.widget.horizontalscrollview2;

import java.util.ArrayList;
import java.util.List;

import com.android.widget.demo.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import com.android.widget.horizontalscrollview2.MyHorizontalScrollView.CurrentImageChangeListener;
import com.android.widget.horizontalscrollview2.MyHorizontalScrollView.OnItemClickListener;

public class HorizontalScrollViewDemo2 extends Activity {

	private MyHorizontalScrollView mHorizontalScrollView;
	private HorizontalScrollViewAdapter mAdapter;
	private ImageView mImg;
	private List<Integer> mDatas = new ArrayList<Integer>();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_horizontal_scroll_view2);

		mImg = (ImageView) findViewById(R.id.id_content);

		Integer resource = R.drawable.pic1;
		for (int i = 0; i < 30000; i++)
			mDatas.add(resource);

		mHorizontalScrollView = (MyHorizontalScrollView) findViewById(R.id.id_horizontalScrollView);
		mAdapter = new HorizontalScrollViewAdapter(this, mDatas);
		mHorizontalScrollView.setCurrentImageChangeListener(new CurrentImageChangeListener() {
					@Override
					public void onCurrentImgChanged(int position,
							View viewIndicator) {
						/*
						mImg.setImageResource(mDatas.get(position));
						viewIndicator.setBackgroundColor(Color
								.parseColor("#AA024DA4"));
								*/
					}
				});
		mHorizontalScrollView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onClick(View view, int position) {
				mImg.setImageResource(mDatas.get(position));
//				view.setBackgroundColor(Color.parseColor("#AA024DA4"));
			}
		});
		mHorizontalScrollView.initData(mAdapter);
	}

}
